package com.jindy.module.statement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.statement.domain.StatementApproval;
import com.jindy.module.statement.service.IStatementApprovalService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 对账单审批Controller
 * 
 * @author jindy
 * @date 2023-03-18
 */
@RestController
@RequestMapping("/module/statementapproval")
public class StatementApprovalController extends BaseController
{
    @Autowired
    private IStatementApprovalService statementApprovalService;

    /**
     * 查询对账单审批列表
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:list')")
    @GetMapping("/list")
    public TableDataInfo list(StatementApproval statementApproval)
    {
        startPage();
        List<StatementApproval> list = statementApprovalService.selectStatementApprovalList(statementApproval);
        return getDataTable(list);
    }

    /**
     * 导出对账单审批列表
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:export')")
    @Log(title = "对账单审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StatementApproval statementApproval)
    {
        List<StatementApproval> list = statementApprovalService.selectStatementApprovalList(statementApproval);
        ExcelUtil<StatementApproval> util = new ExcelUtil<StatementApproval>(StatementApproval.class);
        util.exportExcel(response, list, "对账单审批数据");
    }

    /**
     * 获取对账单审批详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(statementApprovalService.selectStatementApprovalById(id));
    }

    /**
     * 新增对账单审批
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:add')")
    @Log(title = "对账单审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StatementApproval statementApproval)
    {
        return toAjax(statementApprovalService.insertStatementApproval(statementApproval));
    }

    /**
     * 修改对账单审批
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:edit')")
    @Log(title = "对账单审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StatementApproval statementApproval)
    {
        return toAjax(statementApprovalService.updateStatementApproval(statementApproval));
    }

    /**
     * 删除对账单审批
     */
    @PreAuthorize("@ss.hasPermi('module:statementapproval:remove')")
    @Log(title = "对账单审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(statementApprovalService.deleteStatementApprovalByIds(ids));
    }
}
